package nbcp.db.mongo.repository.sys


import nbcp.db.mongo.*
import nbcp.db.mongo.entity.*;
import nbcp.db.mongo.*

/**
 * Created by nbcp on 2017/3/23.
 */

//interface SysCorporationRepository : MongoRepository<SysCorporation, ObjectId> {
//}


//fun SysCorporation.PatchHostUrl(downloadHost: String) {
//    this.logo.url = this.logo.url.PatchHostUrl(downloadHost)
//
//    this.images.forEach {
//        it.url = it.url.PatchHostUrl(downloadHost);
//    }
//
//    this.qualifications.forEach {
//        it.url = it.url.PatchHostUrl(downloadHost);
//    }
//}

fun  SysCorporation.JwdLock(lockMessage: String): String {
    mor.system.sysCorporation
            .updateById(this.id)
            .set(mor.system.sysCorporation.isLocked, true)
            .set(mor.system.sysCorporation.lockedRemark, lockMessage)
            .exec()

    if (mor.affectRowCount == 0) {
        return "锁定${this.name}时更新企业信息失败"
    }

    return "";
}

fun SysCorporation.JwdUnLock(): String {
    mor.system.sysCorporation
            .updateById(this.id)
            .set(mor.system.sysCorporation.isLocked, false)
            .set(mor.system.sysCorporation.lockedRemark, "")
            .exec()

    if (mor.affectRowCount == 0) {
        return "解锁${this.name}时更新企业信息失败"
    }

    return "";
}


